Moving Objects With DXL Strange Behavior

I'm trying to rearrange data in a DOORS module using DXL and for the most part I'm successful but there is one quirk that I can't quite figure out. I'm looping all object in my module and storing the integer value of an attribute called "_TFS ID". For each object I'm then going through the module again, object by object, and looking at the integer value of an attribute called "_Parent". If I find an object with the same a "_Parent" integer value as my "_TFS" integer value I know I have found a parent child relationship. However I'm noticing some strange behavior if there are child objects above the parent object. It seems that a single child will be re-parented correctly and then all other objects are ignored. Below is my code and some visuals of my situation. What I would like to know is if this should be happening and if so I'm not sure how I can create a parent-child relationship correctly.

 

Module m = current
Object oA = current
Object oB = null

for oA in m do
{
        print "oA: " oA."Absolute Number" "\n"

        // Get the TFS ID of each object
        int iA = intOf(oA."_TFS ID" "")

        // Loop through all the object in the module
        for oB in m do
        {
                print "\toB: " oB."Absolute Number" "\n"

                // Get the Parent Id of each object
                int iB = intOf(oB."_Parent" "")

                // If the TFS ID of the current object is equal
                // to the parent id of any object we have found a parent
                // child relationship.
                if (iA == iB)
                {
                        // Get the parent object of the child
                        oP = parent(oB)

                        // Make sure it is not null or DOORS does not
                        // like comparing it.
                        if (oP != null)
                        {
                                if (oP != oA)
                                {
                                        move(oB, last(below(oA)))
                                }
                        }
                        else
                        {
                                if (oB."_Parent" "" != "-1")
                                {
                                        move(oB, last(below(oA)))
                                }
                        }    
                }
        }
}
Module Structure      
Object ID Object Number _Parent _TFS ID
9176 1 6 4
9181 2 6 8
9177 3 6 2
9175 4 -1 6

 

After running the DXL the module looks like this:

Module Structure      
Object ID Object Number _Parent _TFS ID
9181 1 6 8
9177 2 6 2
9175 3 -1 6
9176 3.1 6 4

And here is the console output of the print statements. This is what leads me to believe that after re-parenting 9176 DOORS just ignores the other objects.

// --------------
// Console Output
// --------------
// oA: 9176
//      oB: 9176
//      oB: 9181
//      oB: 9177
//      oB: 9175
// oA: 9181
//      oB: 9176
//      oB: 9181
//      oB: 9177
//      oB: 9175
// oA: 9177
//      oB: 9176
//      oB: 9A81
//      oB: 9177
//      oB: 9175
// oA: 9175
//      oB: 9176
// oA: 9176
//      oB: 9181
//      oB: 9177
//      oB: 9175
//      oB: 9176

 


PumpTest - Fri Oct 09 10:52:17 EDT 2015

Re: Moving Objects With DXL Strange Behavior
Pekka_Makinen - Fri Oct 09 13:33:54 EDT 2015

You are moving objects which are variables for a for loop - it is hard to find in the documentation but that is generally not a good idea.

See this thread and especially the answer by Peter Albert:  https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014461930